#region "ContextVariables"

/*
 * ####     Developer Name : Wang Yucai
 * 
 * ####     Development Tool : Microsoft VisualStudio 2010 Ultimate Edition
 * 
 * ####     Create Time : 2014-07-09 14:06:03
 * 
 * ####     Namespace : Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime
 * 
 * ####     Type Name : ContextVariables
 * 
 * ####     Full Name : Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime.ContextVariables
 * 
 * ####     Machine Name : GLCHQWYCWINW7
 * 
 * ####     UserName : GUOCOLAND/wangyucai
 * 
 * ####     CLR Version : 4.0.30319.18444
 * 
 * ####     Target Framework Version : 4.0
 */

#endregion

using System;

namespace Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime
{
    /// <summary>
    /// <para>Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime.ContextVariables</para>
    /// <para>
    /// 提供了获取应用运行时上下文变量的方法。
    /// </para>
    /// </summary>
    /// <remarks>
    /// <para>Target Framework Version : 4.0</para>
    /// </remarks>
    public class ContextVariables
    {
        private string _currentRunningDirectory;
        private string _friendlyName;
        private ClrVersion _clrVersion;
        private WindowsOperationVersion _windows;
        private string _machineName;
        private string _userName;
        private string _userDomain;
        static private ContextVariables _context;

        #region Context
        /// <summary>
        /// 获取与当前应用相关的上下文变量。
        /// </summary>
        static public ContextVariables Context
        {
            get
            {
                if (_context.IsNull()) _context = new ContextVariables();
                return _context;
            }
        }
        #endregion

        #region CurrentRunningDirectory
        /// <summary>
        /// 获取当前应用的运行目录路径。
        /// </summary>
        public virtual string CurrentRunningDirectory
        {
            get { return _currentRunningDirectory; }
            protected set { _currentRunningDirectory = value; }
        }
        #endregion

        #region FriendlyName
        /// <summary>
        /// 获取当前应用的友好名称。
        /// </summary>
        public virtual string FriendlyName
        {
            get { return _friendlyName; }
            protected set { _friendlyName = value; }
        }
        #endregion

        #region CLR
        /// <summary>
        /// 获取当前计算机安装的CLR版本信息。
        /// </summary>
        public virtual ClrVersion CLR
        {
            get { return _clrVersion; }
            protected set { _clrVersion = value; }
        }
        #endregion

        #region Windows
        /// <summary>
        /// 获取当前计算机Windows操作系统的版本信息。
        /// </summary>
        public virtual WindowsOperationVersion Windows
        {
            get { return _windows; }
            protected set { _windows = value; }
        }
        #endregion

        #region MachineName
        /// <summary>
        /// 获取当前计算机在网络中的机器名。
        /// </summary>
        public virtual string MachineName
        {
            get { return _machineName; }
            protected set { _machineName = value; }
        }
        #endregion

        #region UserName
        /// <summary>
        /// 获取当前登录的用户名。
        /// </summary>
        public virtual string UserName
        {
            get { return _userName; }
            protected set { _userName = value; }
        }
        #endregion

        #region UserDomain
        /// <summary>
        /// 获取当前登录的用户所在的域。
        /// </summary>
        public virtual string UserDomain
        {
            get { return _userDomain; }
            protected set { _userDomain = value; }
        }
        #endregion

        #region Constructor

        /// <summary>
        /// <para>构造函数：</para>
        /// <para>初始化一个<see cref="ContextVariables" />对象实例。</para>
        /// </summary>
        protected ContextVariables()
        {
            this.CurrentRunningDirectory = AppDomain.CurrentDomain.BaseDirectory;
            this.FriendlyName = AppDomain.CurrentDomain.FriendlyName;
            this.CLR = new ClrVersion();
            this.Windows = new WindowsOperationVersion();
            this.MachineName = Environment.MachineName;
            this.UserDomain = Environment.UserDomainName;
            this.UserName = Environment.UserName;

        }

        #endregion
    }
}

#region README

/*
 * ####     ©2014 Wang Yucai
 * 
 * ####     Contact me
 *                  
 *                  E-mail : Masterduner@Yeah.net
 *                  Mobile : 13621384677
 *                  QQ : 180261899
 */

#endregion